#!/usr/bin/python

import sys

count_hash = {}


for eachLine in sys.stdin:
    eachLine = eachLine.strip()
    
    art_name = eachLine.split("\t")[0]
    if(art_name == "*"):
        if(count_hash.has_key(eachLine) == False):
            count_hash[eachLine] = 0
            
        count_hash[eachLine] += 1
        
    else:
        if(eachLine.strip()!=""):
            print eachLine+"\t"+str(len(eachLine.split("\t"))-1)



for eachKey in count_hash.keys():
    print eachKey+"\t"+str(count_hash[eachKey])

